package com.ecar.common.util;

import java.util.HashMap;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * 通用日志工具
 * 
 */
public class LoggerUtil {
	protected static Logger appLogger = LoggerFactory.getLogger("appLogger");

	protected static Logger allLogger = LoggerFactory.getLogger("fileLogger");
	
	protected static Logger errorLogger = LoggerFactory.getLogger("errorLogger");
	protected static Map<String, Logger> loggers = new HashMap<String, Logger>();

	public static Logger getLogger(String name) {
		Logger logger = loggers.get(name);
		if (logger == null) {
			synchronized (loggers) {
				logger = LoggerFactory.getLogger(name);
				loggers.put(name, logger);
			}
		}
		return logger;
	}

	public static Logger getAppLogger() {
		return appLogger;
	}

	public static Logger getFileLogger() {
		return allLogger;
	}

	public static Logger getErrorLogger() {
		return errorLogger;
	}

}
